<template>
  <view class="container">
    <!-- 轮播图 -->
    <view class="swiper">
      <u-swiper :list="listswiper" height="180"></u-swiper>
      <view class="navbox">
        <view class="navson" v-for="(item, i) in navlist" :key="i">
          <image class="navimg" :src="item.url" mode="widthFix"></image>
          <view class="navtext">{{ item.text }}</view>
        </view>
      </view>
    </view>
    <!-- 轮播图 -->
    <view style="height: 100rpx"></view>
    <!-- 赛事信息 -->
    <view class="infobox">
      <view class="infotit">赛事信息</view>
      <view class="infoson" v-for="(item, i) in infolist" :key="i">
        <image :src="item.url" mode="widthFix" class="infoimg"></image>
        <view class="label" :class="item.label == '已结束' ? 'nolabel' : ''">
          {{ item.label }}
        </view>
        <view class="infotext">
          <view class="itleft">
            <view class="ittit"> {{ item.tit }} </view>
            <view class="ittext">{{ item.age }} </view>
          </view>
          <view class="itright">
            <view class="time">{{ item.time }}</view>
            <button class="but">{{ item.but }}</button>
          </view>
        </view>
      </view>
    </view>
    <!-- 赛事信息 -->
    <!-- 赛事介绍 -->
    <view class="introbox">
      <view class="infotit">赛事介绍</view>
      <view class="intro">
         <rich-text :nodes="richText"></rich-text>
      </view>
    </view>
    <!-- 赛事介绍 -->
  </view>
</template>

<script setup>
import { onMounted, ref } from "vue";

const listswiper = ref([
  {
    id: 1,
    url: "/static/index/bgimg.png",
  },
  {
    id: 2,
    url: "/static/index/bgimg.png",
  },
  {
    id: 3,
    url: "/static/index/bgimg.png",
  },
]);

const navlist = ref([
  {
    id: 1,
    url: "/static/index/nav1.png",
    text: "活动报名",
  },
  {
    id: 2,
    url: "/static/index/nav2.png",
    text: "竞赛答题",
  },
  {
    id: 3,
    url: "/static/index/nav3.png",
    text: "增值服务",
  },
  {
    id: 4,
    url: "/static/index/nav2.png",
    text: "证书查询",
  },
]);

const infolist = ref([
  {
    url: "/static/index/info.png",
    tit: "舞动奇迹",
    age: "18-18-25岁可报名参加",
    time: "2023.12.15-2023.12.30",
    path: "",
    label: "进行中",
    but: "马上报名",
  },
  {
    url: "/static/index/info.png",
    tit: "舞动奇迹",
    age: "18-18-25岁可报名参加",
    time: "2023.12.15-2023.12.30",
    path: "",
    label: "进行中",
    but: "马上报名",
  },
  {
    url: "/static/index/info.png",
    tit: "舞动奇迹",
    age: "18-18-25岁可报名参加",
    time: "2023.12.15-2023.12.30",
    path: "",
    label: "已结束",
    but: "已结束",
  },
]);

const richText = ref([
  {
    name: 'div',
    attrs: {
      class: 'div_class',
      style: 'line-height: 60px; color: red;'
    },
    children: [{
      type: 'text',
      text: 'Hello World!'
    }]
  }
]);
</script>

<style lang="scss" scoped>
.swiper {
  position: relative;
  width: 100%;

  .navbox {
    width: 88%;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: space-between;

    .navson {
      width: 22%;
      aspect-ratio: 1;
      //从上向下渐变背景颜色
      background: linear-gradient(180deg, #8554db 0%, #4044da 100%);
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      border-radius: 16rpx;
      color: white;

      .navimg {
        width: 50rpx;
        max-width: 100%;
        margin-bottom: 16rpx;
      }

      .navtext {
        font-size: 16rpx;
        display: flex;
        flex-direction: flex-end;
      }
    }
  }
}

// 赛事信息
.infotit {
  width: 100%;
  text-align: center;
  font-weight: bold;
  margin: 0 auto;
  display: inline-block;
  font-size: 40rpx;
  margin-bottom: 40rpx;
}
.infotit::after {
  content: "";
  display: block;
  width: 25%;
  height: 6rpx;
  background: #8554db;
  margin: auto;
  margin-top: 8rpx;
  border-radius: 8rpx;
}
.infobox {
  width: 90%;
  margin: auto;

  .infoson {
    position: relative;
    margin-bottom: 40rpx;
    background-color: #fff;

    .infoimg {
      width: 100%;
    }
  }

  .label {
    position: absolute;
    top: -16rpx;
    left: -20rpx;
    display: inline-block;
    padding: 6rpx 30rpx;
    background-color: #8c57e3;
    color: white;
    border-bottom-right-radius: 16rpx;
    border-top-left-radius: 16rpx;
  }
  .nolabel {
    position: absolute;
    top: -16rpx;
    left: -20rpx;
    display: inline-block;
    padding: 6rpx 30rpx;
    background-color: #8d8d8d;
    color: white;
    border-bottom-right-radius: 16rpx;
    border-top-left-radius: 16rpx;
  }

  .infotext {
    display: flex;
    justify-content: space-between;
    margin-top: 20rpx;
    align-items: center;
    padding: 20rpx 20rpx;
    box-sizing: border-box;

    .itleft {
      text-align: left;
      .ittit {
        margin-bottom: 20rpx;
        font-weight: bold;
      }

      .ittext {
        font-size: 16rpx;
        color: #aaaaaa;
      }
    }
    .itright {
      text-align: right;
      .time {
        font-size: 16rpx;
        color: #aaaaaa;
        margin-bottom: 20rpx;
      }
      .but {
        width: 200rpx;
        height: 40rpx;
        background: linear-gradient(180deg, #8554db 0%, #4044da 100%);
        border-radius: 20rpx;
        color: white;
        font-size: 16rpx;
        line-height: 40rpx;
      }
    }
  }
}
// 赛事信息
// 赛事介绍
.introbox {
  width: 90%;
  margin: auto;
  .intro{
    width: 100%;
    padding: 20rpx;
    box-sizing: border-box;
    background-color: #fff;
    border-radius: 16rpx;
  }
}
// 赛事介绍
</style>
